package com.unity3d.sp_qqdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView textView = findViewById(R.id.textview);
        //通过文件名获取到user文件
        SharedPreferences sp=getSharedPreferences("user",MODE_PRIVATE);
        //取出键名为username的用户名
        String userName=sp.getString("username","");
        //将用户名设置到文本组件中
        textView.setText(userName);

    }
}